function [lambda_x]=ud_fixedpoint(n_g,singles_moments, data_f, data_m, lambda_mcd, Uf_grid_ud, Um_grid_ud, U_f0_ud, U_m0_ud, Lini_grid_norep)

lambda_x=zeros(n_g,1);
valfun=zeros(n_g,1);
singlef_mu=ones(1,n_g)*0.9; 
singlem_mu=ones(1,n_g)*0.9;
x0=lambda_mcd; 
single_mu=[singlef_mu;singlem_mu]; 
eps_single=single_mu;
tolerance=0.0001;

options = optimoptions('fsolve','Display','iter','FunctionTolerance',1.0e-6,'StepTolerance',1e-100,'MaxFunctionEvaluations',2000);

while max(eps_single)>tolerance

singlef_mu_ini=singlef_mu; 
singlem_mu_ini=singlem_mu; 
single_mu_ini=[singlef_mu';singlem_mu'];
delta_single=log(singlem_mu_ini)-log(singlef_mu_ini); 

for g=1:n_g
[x,fval] = fsolve(@(x) mkt_clr_eq(Lini_grid_norep, Uf_grid_ud, Um_grid_ud, U_f0_ud, U_m0_ud, x, delta_single, g),x0(g),options); 
lambda_x(g)=x;
valfun(g)=fval;
end                                               

[singlef_mu, singlem_mu, single_mu]= updatesingle(Lini_grid_norep, Uf_grid_ud, Um_grid_ud, U_f0_ud, U_m0_ud, lambda_x, data_f, data_m, n_g);  
eps_single=abs(single_mu-single_mu_ini);

end

end

















